import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import { createPinia } from 'pinia'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import axios from 'axios'
import request from './utils/request'
import permissionDirectives from './directives/permission'

import './style.css'

// 创建应用实例
const app = createApp(App)

// 注册所有图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}

// 全局注册 axios 实例
app.config.globalProperties.$axios = request

// 注册Pinia状态管理
app.use(createPinia())

// 注册路由
app.use(router)

// 注册Element Plus
app.use(ElementPlus, { size: 'default' })

// 注册权限指令
app.use(permissionDirectives)

// 挂载应用
app.mount('#app')
